<?php

/**
 * Class for rendering a script tag element.
 *
 * @author Ian Clarence <ian.clarence@gmail.com>
 */
class ViewScript extends ViewHtmlElement {

    /**
     * Flag indicating whether there is any whitespace in the inner HTML.
     */
    const NO_WHITESPACE = TRUE;

    /**
     * Constants for JavaScript
     */
    const JS_TYPE = "text/javascript";

    /**
     * The constructor.
     *
     * @param array $fields
     */
    public function __construct(array $fields = array()) {

        $fields["tag"] = "script";
        $fields["type"] = isset($fields["type"]) ? $fields["type"] : self::JS_TYPE;

        parent::__construct($fields);
        
        $this->setAttribute("type", $this->getType());

        if (isset($this->fields["src"])) {
            $this->setAttribute("src", $this->getSrc());
        }

        if (isset($this->fields["charset"])) {
            $this->setAttribute("charset", $this->getCharset());
        }

    }

}